package com.bustle.web.mbean.session;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import com.bustle.ejb.entity.User;
import com.bustle.ejb.service.AuthenticationManager;

@ManagedBean(name = "user")
@SessionScoped
public class UserMBean
{
  public String update()
  {
    User user = authenticationManager.getUser(id);
    user.setFirstName(firstName);
    user.setLastName(lastName);
    authenticationManager.updateUser(user);
    return null;
  }

  public Integer getId()
  {
    return id;
  }

  public void setId(Integer anId)
  {
    id = anId;
  }

  public String getFirstName()
  {
    return firstName;
  }

  public void setFirstName(String aFirstName)
  {
    firstName = aFirstName;
  }

  public String getLastName()
  {
    return lastName;
  }

  public void setLastName(String aLastName)
  {
    lastName = aLastName;
  }

  protected Integer id;
  protected String firstName;
  protected String lastName;

  @EJB
  protected AuthenticationManager authenticationManager;

  static public final String SCREEN = "user.jsf";
}
